Page({
  data:{
    post:0,
    departmentDefault:0,
    department_sDefault:0,
    fromData:{}
  },
  async onShow(){
    wx.showLoading({
      title: '加载中',
    });
    wx.showNavigationBarLoading()
    const res=await getApp().httpModule.getfromData();
    const fromData=res.data.fromData.fromData
    console.log(fromData);
    this.setData({fromData})
    wx.hideLoading();
    wx.hideNavigationBarLoading()
  },
  zhuce(){
    wx.showToast({
      icon:'none',
      title: '注册成功',
    })
  },
  changeDf(e){
    const value=e.detail.value;
    this.setData({
      departmentDefault:parseInt(value)
    })
    console.log(value)
  },
  changeDs(e){
    const value=e.detail.value;
    this.setData({
      department_sDefault:parseInt(value)
    })
    console.log(value)
  },
  postChange(e){
    const value=e.detail.value;
    this.setData({
      post:parseInt(value)
    })
    console.log(value)
  },
  
  async formSubmit(e){
    const value=e.detail.value;
    value.post_id=this.data.fromData.post[this.data.post].post_id;
    value.department_id=this.data.fromData.departments[this.data.departmentDefault].son.length?this.data.fromData.departments[this.data.departmentDefault].son[this.data.department_sDefault].id:this.data.fromData.departments[this.data.departmentDefault].id;
    console.log(value)
    if(!Object.values(value).some(v=>v=='')){
  await getApp().httpModule.userZhuce(value);
    wx.redirectTo({
      url: '/pages/index/index',
    })
   
    
    }else{
      console.log('没填完')
      wx.showToast({

        title: '信息必须填写完整',
   
        icon: "none",
   
        duration: 2000//持续的时间
   
      })
      return false;
    
    }
  
   
  
  }
})